package com.kkang.ch2.scope;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author yongk_liu
 **/
public class Main {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScopeConfig.class);
        //singletion 获取两次bean
        DemoSingetonService singetonBean1 = context.getBean(DemoSingetonService.class);
        DemoSingetonService singetonBean2 = context.getBean(DemoSingetonService.class);
        //prototype 获取两次bean
        DemoPrototypeService prototypeBean1 = context.getBean(DemoPrototypeService.class);
        DemoPrototypeService prototypeBean2 = context.getBean(DemoPrototypeService.class);
        System.out.println("singleton 两个对象相等？" + singetonBean1.equals(singetonBean2));
        System.out.println("prototype 两个对象相等？" + prototypeBean1.equals(prototypeBean2));

        context.close();
    }
}
